package com.lilili.ssh.book.dao.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.lilili.ssh.book.dao.BookDao;
import com.lilili.ssh.book.model.Book;
public class BookDaoImpl extends HibernateDaoSupport implements BookDao{
	
	public void saveBook(Book Book){
		if(Book!=null&&StringUtils.isNotEmpty(Book.getId())){
			getHibernateTemplate().saveOrUpdate(Book);
		}else{
			getHibernateTemplate().save(Book);
		}
	}
	
	public void removeBook(String id){
		getHibernateTemplate().delete(getBook(id));
	}
	
	public Book getBook(String id){
		return (Book)getHibernateTemplate().get(Book.class, id);
	}
	
	public List getBookList(Book Book){
		return null;
	}
	
    public List getBookList(){
    	return getHibernateTemplate().find("from Book Book");
	}
	
}
